package com.appsys.filter;


import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName NoCacheFilter
 * @Description TODO
 * @Author YinLiangTao Email:1517535831@qq.com
 * @Date 2022/3/25 15:50
 * @Version 1.0
 */
public class NoCacheFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletResponse hsr = (HttpServletResponse)  servletResponse;
        hsr.setHeader("Cache-Control","no-cache,no-store,must-revalidate");
        hsr.setHeader("Pragma","no-cache");
        hsr.setDateHeader("Expires",0);
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {

    }
}
